<?php

namespace common\validate;

use think\Validate;

class ChatUser extends BaseValidate
{
    //验证规则
    protected $rule = [];

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.name', 'require|max:128')
            ->append('data.code', 'max:128');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.name', 'max:128')
            ->append('data.code', 'max:128');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require|array');
    }

    // UpdateByGlobalId 验证规则定义
    public function sceneUpdateByChatGlobalId()
    {
        return $this->append("data.chat_global_id", "require");
    }

    // InviteUser 验证规则定义
    public function sceneInviteUser()
    {
        return $this
            ->append("data.user_id", "require|array")
            ->append("data.chat_global_id", "require");

    }

    // InviteUser 验证规则定义
    public function sceneInviteUsersOrDepartments()
    {
        return $this->append("id", "require")
            ->append("type", "require");
    }

    public function sceneInviteUsersOrDepartment()
    {
        return $this
            ->append("data.chat_global_id", "require")
            ->append("data.receiver", "require");

    }

    // DeleteUser 验证规则定义
    public function sceneDeleteUser()
    {
        return $this
            ->append("param.filter.user_id", "require")
            ->append("param.filter.chat_global_id", "require");
    }

    // TransferAdmin 验证规则定义
    public function sceneTransferAdmin()
    {
        return $this
            ->append("data.user_id", "require|integer")
            ->append("data.chat_global_id", "require");
    }

    // DeleteAndExit 验证规则定义
    public function sceneDeleteAndExit()
    {
        return $this->append("param.filter", "require")
            ->append("param.filter.chat_global_id", "require");
    }

    public function SceneGetInviteUserInfo()
    {
        return $this->append("data.receiver", "require");
    }

    public function sceneAddMultipleUser()
    {
        return $this->append("data", "require|array");
    }

    public function sceneAddMultipleUserItem()
    {
        $this->append("chat_global_id", "require")
            ->append("user_id", "require|integer")
            ->append("join_at", "require|integer");
    }
}
